<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head><link rel="stylesheet" type="text/css" href="<c:url value='/css/Pub.css'/>"></link>
	<title>一张订单的信息</title>
	<script type="text/javascript">
        var path = "<c:url value='/'/>";
	</script>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!-- 如果出现没有效果的情况直接检查是否是因为路径的问题 -->
	<link rel="stylesheet" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" type="text/css"></link>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/easyui/themes/icon.css" type="text/css"></link>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
	<style type="text/css">td,th{
		text-align:center
	}</style>
	<style type="text/css">
		a {
			text-decoration:none;
		}
	</style>
</head>

<body>
<p>选择/输入送货地址->订单明细-->选择/添加收货地址-><font color="red" style="font-family:bold;">确认订单</font>->网银付款或到货付款->查收货物</p>

<p>订单明细：</p>

<table id="table" class="easyui-datagrid" style="width:800px;height:350px"
	   data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
	<thead>
	<tr>
		<th data-options="field:'orderid',width:100">书名</th>
		<th data-options="field:'orderconsignee',width:150">价格</th>
		<th data-options="field:'orderamt',width:100">数量</th>
		<th data-options="field:'orderstate',width:100">合计</th>
	</tr>
	</thead>

	<tbody>

	<c:set value="0" var="sum"/>
	<c:forEach items="${sessionScope.car}" var="entry" varStatus="idx">
		<tr <c:if test="${idx.count%2==0}">class="even"</c:if>>
			<td>
				<a href="${pageContext.request.contextPath }/index?action=queryBook&id=${entry.value.id}">
						${entry.value.name}
				</a>
			</td>
			<td>
					${entry.value.currentPrice}
			</td>
			<td>
					${entry.value.amt}
			</td>
			<td>
				<fmt:formatNumber value="${entry.value.currentPrice*entry.value.amt}" pattern="#.##"/>
				<c:set value="${sum+(entry.value.currentPrice*entry.value.amt)}" var="sum"/>
				<fmt:formatNumber value="${sum}" pattern="#.##" var="sum"/>
			</td>
		</tr>
	</c:forEach>
	<tr ><td></td><td></td><td></td>
		<td>
			总金额：
			<label id="sum">
			${sum}
			</label>
			元
		</td>
	</tr>

	</tbody>
</table>
<p>订单的信息</p>
<form name="order" action="${pageContext.request.contextPath}/order?action=save" method="post">
	<table  class="easyui-datagrid" style="width:1000px;height:350px"
			data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
		<thead>
		<tr>
			<th data-options="field:'code',width:100">订单类别</th>
			<th data-options="field:'name',width:100">订单结果</th>
			<th data-options="field:'haha',width:100"></th>
		</tr>
		</thead>
		<tbody>
		<tr>
			<td >订单编号：</td>
			<td><input class="txt" readonly="readonly" type="text" name="id"  id="id" value="${requestScope.order.id}"/></td>
		</tr>
		<tr>
			<td >收货人/地址：</td>
			<td><input class="txt" readonly="readonly" type="text" name="consignee" id="consignee" value="${requestScope.order.consignee}"/></td>
		</tr>
		<tr>
			<td style="text-align:center;">总金额：</td>
			<td><input  style="text-align:center;" readonly="readonly" type="text" name="amt" id="amt" value="${sum}元" /></td>
		</tr>
		     <tr>
				 <td >支付方式:</td>
				 <td>
					 <select name="paytype">
						 <option value="1" selected="selected">货到付款</option>
						 <option value="2">网银付款</option>
					 </select>
		         </td>
		    </tr>
		<tr>
			<td></td>
			<td >
				<button class="OperBtn" onclick="sure();return false;" style="width:150px;">确认订单</button>
			</td>
		</tr>
		</tbody>
	</table>
</form>
</body>
<script type="text/javascript">
//form表单如果放在table外面那么就需要再sure()方法后面加个return false;具体原因是因为这样可以
//阻止浏览器的默认行为
    function sure(){
        var boo = $.messager.confirm('提交', '您提交订单吗？', function(boo){
            if(boo){
                document.forms['order'].submit();
            }
        });
    }
</script>
</html>
